package com.bls.cate.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bls.cate.R;
import com.bls.cate.model.AttentionListRes;
import com.bls.cate.utils.FrescoImageLoader;
import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

/**
 * 　　  () 　　　  ()
 * 　　  ( ) 　　　( )
 * 　　  ( ) 　　　( )
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　━　　　┃
 * 　　┃　┳┛　┗┳　┃
 * 　　┃　　　┻　　　┃
 * 　　┗━┓　　　┏━┛
 * 　　　　┃　　　┃
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣┓
 * 　　　　┃　　　　　　　┏┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 * ——————————————————
 * Created by BinglingSu on 2018/1/25.
 */

public class AttentionListAdapter extends BaseQuickAdapter<AttentionListRes.ResultListDataBean, BaseViewHolder> {

    private Context context;
    private AttentionListAdapterListener listener;

    public enum ButtonType {RL_ROOT, BTN_DEL}

    public AttentionListAdapter(Context context, @Nullable List<AttentionListRes.ResultListDataBean> data, AttentionListAdapterListener listener) {
        super(R.layout.item_attention_list, data);
        this.context = context;
        this.listener = listener;
    }

    @Override
    protected void convert(BaseViewHolder helper, AttentionListRes.ResultListDataBean item) {
        final int position = helper.getAdapterPosition();
        RelativeLayout rlRoot = helper.getView(R.id.rl_root);
        SimpleDraweeView ivHeader = helper.getView(R.id.iv_header);
        TextView tvName = helper.getView(R.id.tv_name);
        TextView btnDel = helper.getView(R.id.btn_del);
        FrescoImageLoader.showImage(ivHeader, item.getOtherHeaderImgSmall());
        if (null != item.getOtherNickName())
            tvName.setText(item.getOtherNickName());
        rlRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onAttentionListAdapterListener(ButtonType.RL_ROOT, position);
            }
        });
        btnDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onAttentionListAdapterListener(ButtonType.BTN_DEL, position);
            }
        });
    }

    public interface AttentionListAdapterListener {
        void onAttentionListAdapterListener(ButtonType buttonType, int position);
    }
}
